// components/authorization/authorization.js
Component({
  data: {
    isLogin: true
  },
  lifetimes: {
    attached() {
      const app = getApp()
      const token = app.getToken()
      this.setData({ isLogin: !!token })
      const pages = getCurrentPages()
      const page = pages[pages.length - 1]
      if (!token) {
        wx.redirectTo({
          url: '/pages/login/index?redirectURL=/' + page.route
        })
      }
    }
  }
})
